package com.house.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.house.dto.MessageDTO;
import com.house.entity.Message;
import com.house.reportisy.MessageRepository;
import com.house.service.MessageService;
import com.house.vo.MessageVO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author: GGP
 * @description: 留言实现类
 * @time: 2023-04-17 21:42
 **/
@Service
public class MessageServiceImpl implements MessageService {

	@Resource
	private MessageRepository messageRepository;

	@Override
	public List<Map<String,Object>> findAllMessage(MessageDTO messageDTO) {
		return messageRepository.findAllMessage(messageDTO.getHouseId());
	}

	@Override
	public Message saveMessage(MessageDTO messageDTO) {
		Message message = new Message();
		BeanUtil.copyProperties(messageDTO,message);
		return messageRepository.save(message);
	}
}
